package cardcreator;

import java.awt.Dimension;

import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.BevelBorder;

public class CardCreator {
	private static final String[] CARDTYPES = {"Group","Illuminati","Action"};
	private JFrame _frame = new JFrame("FNORD Card Creator: Destroy the World in Style!");
	private JPanel _content = new JPanel();
	
	private JPanel _editor = new JPanel();
	private JPanel _global = new JPanel();
	private JLabel _cardtypelabel = new JLabel("Card Type:");
	private JComboBox _cardtype = new JComboBox(CardCreator.CARDTYPES);
	private JLabel _cardnamelabel = new JLabel("Card Name:");
	private JTextField _cardname = new JTextField();
	
	private Preview _preview = new Preview();
	
	private CardCreator() {
		_global.setLayout(new BoxLayout(_global,BoxLayout.X_AXIS));
		_global.add(_cardtypelabel);
		_global.add(Box.createRigidArea(new Dimension(3,0)));
		_global.add(_cardtype);
		_cardtype.addItemListener(_preview);
		_cardtype.setMinimumSize(new Dimension(50,25));
		_cardtype.setPreferredSize(new Dimension(100,25));
		_cardtype.setMaximumSize(new Dimension(Short.MAX_VALUE,25));
		_global.add(Box.createRigidArea(new Dimension(5,0)));
		_global.add(_cardnamelabel);
		_global.add(Box.createRigidArea(new Dimension(3,0)));
		_global.add(_cardname);
		_cardname.setMinimumSize(new Dimension(50,25));
		_cardname.setPreferredSize(new Dimension(100,25));
		_cardname.setMaximumSize(new Dimension(Short.MAX_VALUE,25));
		_cardname.addCaretListener(_preview);
		
		_editor.setLayout(new BoxLayout(_editor,BoxLayout.Y_AXIS));
		_editor.setMinimumSize(new Dimension(375,400));
		_editor.setPreferredSize(new Dimension(400,400));
		_editor.setBorder(BorderFactory.createEmptyBorder(0,3,0,3));
		_editor.add(_global);
		
		_preview.setMinimumSize(new Dimension(200,300));
		_preview.setPreferredSize(new Dimension(300,400));
		_preview.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
		
		_frame.setContentPane(_content);
		_content.setLayout(new BoxLayout(_content,BoxLayout.X_AXIS));
		_frame.setMinimumSize(new Dimension(600,400));
		_content.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
		_content.add(_editor);
		_content.add(_preview);
	}

	private void launchFrame() {
		_frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		_frame.pack();
		_frame.setLocationRelativeTo(null);
		_preview.repaint();
		_frame.setVisible(true);
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		CardCreator cardcreator = new CardCreator();
		cardcreator.launchFrame();
	}
}
